#!/bin/bash
 ethnet=$(ls /sys/class/net/ | grep -v "`ls /sys/devices/virtual/net/`" |grep 1)
   ethnum=$(ls /sys/class/net/ |grep -v 'golonet' |grep -v "`ls /sys/devices/virtual/net/`" |wc -l)
   ethroute=$(ls /sys/class/net/ | grep -v "`ls /sys/devices/virtual/net/`" |grep ww)
   ethroutenum=$(ls /sys/class/net/ | grep -v "`ls /sys/devices/virtual/net/`" |grep $ethroute |wc -l)
   ethwork=$( sudo ethtool $ethnet |grep detected |awk -F ":" '{print $2}')
   ethsort=$(dpkg -l |grep ethtool |wc -l)
if [ $ethnum == 5 ];then
    sudo sed -i "/gateway4/d" /etc/netplan/enp1s0.yaml;sudo netplan apply;;sudo iptables -t nat -A POSTROUTING   -o $ethroute -j MASQUERADE
fi
